package zr.com.thread.pool;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;

public class Consumer implements Runnable {

    public  final LinkedBlockingDeque<String> QUEUE;

    public Consumer(LinkedBlockingDeque<String> QUEUE) {
        this.QUEUE = QUEUE;
    }

    @Override
    public void run() {
        while (Constant.active) {
            try {
                TimeUnit.MICROSECONDS.sleep(10000);
                if (QUEUE.size() > 0) {
                    String str = QUEUE.poll();
                    System.out.println("消费者消费:"+Thread.currentThread().getName()+",值；" + str);
                }
            } catch (InterruptedException e) {
                System.out.println(e);
            }
        }
    }
}
